// [原始数据集] 接口
import { axios } from '@/utils/request';

/**
 * [原始数据集] 获取指定原始数据集的详细信息
 * @params params
 * {
    {"datasourceId":{"required":false,"type":"integer"}},
    {"schema":{"required":false,"type":"string"}},
    {"tableName":{"required":false,"type":"string"}}
   }
 */
export function getDatahubOdsDataset(params) {
  return axios({
    method: 'get',
    url: 'datahub/ods-dataset',
    params
  })
}

/**
 * [原始数据集] 编辑原始数据集
 * @params data
 * {
    {"datasourceId":{"description":"数据源ID","type":"integer"}},
    {"description":{"description":"描述","type":"string"}},
    {"name":{"description":"名称","type":"string"}},
    {"schema":{"description":"schema","type":"string"}},
    {"tableName":{"description":"物理表名","type":"string"}}
   }
 */
export function putDatahubOdsDataset(data) {
  return axios({
    method: 'put',
    url: 'datahub/ods-dataset',
    data
  })
}

/**
 * [原始数据集] 编辑原始数据集字段
 * @params data
 * {
    {"aliasColumnName":{"description":"别名","type":"string"}},
    {"datasourceId":{"description":"数据源ID","type":"integer"}},
    {"description":{"description":"描述","type":"string"}},
    {"originColumnName":{"description":"原始字段名","type":"string"}},
    {"schema":{"description":"schema","type":"string"}},
    {"tableName":{"description":"物理表名","type":"string"}}
   }
 */
export function putDatahubOdsDatasetColumn(data) {
  return axios({
    method: 'put',
    url: 'datahub/ods-dataset/column',
    data
  })
}

/**
 * [原始数据集] 获取指定原始数据集的字段信息
 * @params params
 * {
    {"datasourceId":{"required":false,"type":"integer"}},
    {"schema":{"required":false,"type":"string"}},
    {"tableName":{"required":false,"type":"string"}}
   }
 */
export function getDatahubOdsDatasetColumns(params) {
  return axios({
    method: 'get',
    url: 'datahub/ods-dataset/columns',
    params
  })
}

/**
 * [原始数据集] 分页查询原始数据集
 * @params params
 * {
    {"datasourceId":{"required":false,"type":"integer"}},
    {"name":{"required":false,"type":"string"}},
    {"schema":{"required":false,"type":"string"}},
    {"pageNo":{"required":false,"type":"integer"}},
    {"pageSize":{"required":false,"type":"integer"}}
   }
 */
export function getDatahubOdsDatasetPage(params) {
  return axios({
    method: 'get',
    url: 'datahub/ods-dataset/page',
    params
  })
}

/**
 * [原始数据集] 分页查询原始数据集的数据
 * @params params
 * {
    {"datasourceId":{"required":false,"type":"integer"}},
    {"schema":{"required":false,"type":"string"}},
    {"tableName":{"required":false,"type":"string"}},
    {"sortField":{"required":false,"type":"string"}},
    {"sortOrder":{"required":false,"type":"string"}},
    {"pageNo":{"required":false,"type":"integer"}},
    {"pageSize":{"required":false,"type":"integer"}}
   }
 */
export function getDatahubOdsDatasetRecords(params) {
  return axios({
    method: 'get',
    url: 'datahub/ods-dataset/records',
    params
  })
}

/**
 * [原始数据集] 主动校验
 * @params params
 * {
    {"datasourceId":{"required":false,"type":"integer"}},
    {"scheme":{"required":false,"type":"string"}},
    {"tableName":{"required":false,"type":"string"}},
    {"field":{"required":false,"type":"string"}},
    {"value":{"required":false,"type":"object"}}
   }
 */
export function getDatahubOdsDatasetVerification(params) {
  return axios({
    method: 'get',
    url: 'datahub/ods-dataset/verification',
    headers: { validate: true },
    params
  })
}